/**
 * 模态框
 */
(function () {
    //模态框
    let modalEle = document.querySelector('#myModal');
    //默认关闭按钮 y-modal-close
    let closeBtn = document.querySelector('#y-modal-close');
    //默认确定按钮 y-modal-ok
    let okBtn = document.querySelector('#y-modal-ok');
    modalEle.style.display = 'none'; //默认隐藏

    /**
     * 切换模态框
     */
    function toggleModal() {
        if (modalEle.style.display == 'none') {
            modalEle.style.display = 'block';
        } else {
            modalEle.style.display = 'none';
        }
    }
    //关闭按钮
    closeBtn.addEventListener('click', function () {
        modalEle.style.display = 'none';
    })
    //确定按钮
    okBtn.addEventListener('click', function () {
        modalEle.style.display = 'none';
    })

    window.toggleModal = toggleModal; //暴露toggleModal函数给window对象
})()